-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memoize more type properties #16320
memoize more type properties #16320
Conversation
yes. I've seen jl_has_typevar show up as a hotspot in perf regularly while doing other things. cool :) |
@@ -110,14 +120,17 @@ static int jl_has_typevars__(jl_value_t *v, int incl_wildcard, jl_value_t **p, s | |||
for(i=0; i < l; i++) { | |||
jl_value_t *elt = jl_svecref(t, i); | |||
if (elt != v) { | |||
if (jl_has_typevars__(elt, incl_wildcard, p, np)) | |||
if (jl_has_typevars__(elt, incl_wildcard, p, np)) { | |||
if (expect > 0) assert(expect); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this condition make the assert a no-op?
has-typevars is called pretty heavily during intersection and subtyping so it can be a hot-path also fix jl_new_type_constructor to stop mutating (aka corrupting) the immutable TypeVars it is given as a parameter
have lowering emit the correct TypeVar expression instead of fixing it in the TypeConstructor constructor
have lowering emit the correct TypeVar expression instead of fixing it in the DataType constructor
LGTM. Looks like some commits should be squashed. |
Fortunately, that's now easy to do in GitHub so you can actually just merge this if you want. |
type properties are accessed heavily by subtyping and intersection, so it's generally worthwhile to memoize them upon construction.
@carnaval I think you had separately observed this during profiling? Currently, I've also left in the old code paths and use it verify that the cached value is correct when using a debug build.